
<%-- 
    Document   : oEstrategico
    Created on : 10/04/2010, 03:05:56 PM
    Author     : LAPTOP01
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="/tags/c" prefix="c"%>
<%@ include file="seguridad.jsp"%>
<script src="scripts/ajax.js" language="JavaScript"></script>

<html>
    <script LANGUAGE="JavaScript">


        function validando(){
            var cant = Math.floor(document.getElementById("total").value);
            var inicio = Math.floor(document.getElementById("inicio").value);
            var fin = Math.floor(document.getElementById("fin").value);
            var suma=0;
         
            for(inicio;inicio<=fin;inicio++){
                var num=Math.floor(document.getElementById("mes"+inicio+"FinaMeta").value);
                suma=suma+num;
            }
            if(suma==cant){
                insertar();
            }
            else{
                alert("La suma de los meses habilitados debe ser "+cant);
            }
    
        }


       

        function editarT(codAP,mes1,mes2,mes3,mes4,mes5,mes6,mes7,mes8,mes9,mes10,mes11,mes12,cod){
            document.getElementById("opcionFinaMeta").value=2;
            document.getElementById("codActPer").value=codAP;
            document.getElementById("mes1FinaMeta").value=mes1;
            document.getElementById("mes2FinaMeta").value=mes2;
            document.getElementById("mes3FinaMeta").value=mes3;
            document.getElementById("mes4FinaMeta").value=mes4;
            document.getElementById("mes5FinaMeta").value=mes5;
            document.getElementById("mes6FinaMeta").value=mes6;
            document.getElementById("mes7FinaMeta").value=mes7;
            document.getElementById("mes8FinaMeta").value=mes8;
            document.getElementById("mes9FinaMeta").value=mes9;
            document.getElementById("mes10FinaMeta").value=mes10;
            document.getElementById("mes11FinaMeta").value=mes11;
            document.getElementById("mes12FinaMeta").value=mes12;
            document.getElementById("codFinaMeta").value=cod;
  activar();
        }



        function confirmAction(){
            if (confirm("Se borrara Meta Financiera  \n ¿Esta seguro de continuar? "))
                return true;
            else return false;
        }

        function confirmActionGuardar(){
            if (confirm("Se Guardara los cambios hechos en la pantalla  \n ¿Esta seguro de continuar? "))
                return true;
            else
                return false;
        }

        function eliminar(codFM,codAP){
            if (confirmAction()==false) return;
         
            var idDiv = "divTabla";
            var metodo = "GET";
            var tipo=3;
            var mes1=0;
            var mes2=0;
            var mes3=0;
            var mes4=0;
            var mes5=0;
            var mes6=0;
            var mes7=0;
            var mes8=0;
            var mes9=0;
            var mes10=0;
            var mes11=0;
            var mes12=0;
            var ppto=0;
            var url = "consultasAjax/listarFinaMetaAjax.jsp?mes1="+mes1+"&mes2="+mes2+
                "&mes3="+mes3+"&mes4="+mes4+"&mes5="+mes5+"&mes6="+mes6+"&mes7="+mes7+
                "&mes8="+mes8+"&mes9="+mes9+"&mes10="+mes10+"&mes11="+mes11+"&mes12="+
                mes12+"&codAP="+codAP+"&codFM="+codFM+"&tipo="+tipo+"&ppto="+ppto;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
           activar();
        }

        function insertar(){

            if (confirmActionGuardar()==false) {
                return;
            }
            

            var tipo=document.getElementById("opcionFinaMeta").value;
            var codAP = document.getElementById("codActPer").value;
            var codFM = document.getElementById("codFinaMeta").value;
            var mes1 = document.getElementById("mes1FinaMeta").value;
            var mes2 = document.getElementById("mes2FinaMeta").value;
            var mes3 = document.getElementById("mes3FinaMeta").value;
            var mes4 = document.getElementById("mes4FinaMeta").value;
            var mes5 = document.getElementById("mes5FinaMeta").value;
            var mes6 = document.getElementById("mes6FinaMeta").value;
            var mes7 = document.getElementById("mes7FinaMeta").value;
            var mes8 = document.getElementById("mes8FinaMeta").value;
            var mes9 = document.getElementById("mes9FinaMeta").value;
            var mes10 = document.getElementById("mes10FinaMeta").value;
            var mes11 = document.getElementById("mes11FinaMeta").value;
            var mes12 = document.getElementById("mes12FinaMeta").value;
            var ppto= document.getElementById("total").value;
            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarFinaMetaAjax.jsp?mes1="+mes1+"&mes2="+mes2+
                "&mes3="+mes3+"&mes4="+mes4+"&mes5="+mes5+"&mes6="+mes6+"&mes7="+mes7+
                "&mes8="+mes8+"&mes9="+mes9+"&mes10="+mes10+"&mes11="+mes11+"&mes12="+
                mes12+"&codAP="+codAP+"&codFM="+codFM+"&tipo="+tipo+"&ppto="+ppto;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            document.getElementById("opcionFinaMeta").value=1;

            document.getElementById("mes1FinaMeta").value=0;
            document.getElementById("mes2FinaMeta").value=0;
            document.getElementById("mes3FinaMeta").value=0;
            document.getElementById("mes4FinaMeta").value=0;
            document.getElementById("mes5FinaMeta").value=0;
            document.getElementById("mes6FinaMeta").value=0;
            document.getElementById("mes7FinaMeta").value=0;
            document.getElementById("mes8FinaMeta").value=0;
            document.getElementById("mes9FinaMeta").value=0;
            document.getElementById("mes10FinaMeta").value=0;
            document.getElementById("mes11FinaMeta").value=0;
            document.getElementById("mes12FinaMeta").value=0;
              desactivar();
        }


        function filtradoAPermanente(){
            var tipo=document.getElementById("opcionFinaMeta").value;
            var codAP = document.getElementById("codActPer").value;
            var codFM = document.getElementById("codFinaMeta").value;
            var mes1 = document.getElementById("mes1FinaMeta").value;
            var mes2 = document.getElementById("mes2FinaMeta").value;
            var mes3 = document.getElementById("mes3FinaMeta").value;
            var mes4 = document.getElementById("mes4FinaMeta").value;
            var mes5 = document.getElementById("mes5FinaMeta").value;
            var mes6 = document.getElementById("mes6FinaMeta").value;
            var mes7 = document.getElementById("mes7FinaMeta").value;
            var mes8 = document.getElementById("mes8FinaMeta").value;
            var mes9 = document.getElementById("mes9FinaMeta").value;
            var mes10 = document.getElementById("mes10FinaMeta").value;
            var mes11 = document.getElementById("mes11FinaMeta").value;
            var mes12 = document.getElementById("mes12FinaMeta").value;
            var idDiv = "divTabla";
            var tipo=0;
            var metodo = "GET";
            var url = "consultasAjax/listarFinaMetaAjax.jsp?mes1="+mes1+"&mes2="+mes2+
                "&mes3="+mes3+"&mes4="+mes4+"&mes5="+mes5+"&mes6="+mes6+"&mes7="+mes7+
                "&mes8="+mes8+"&mes9="+mes9+"&mes10="+mes10+"&mes11="+mes11+"&mes12="+
                mes12+"&codAP="+codAP+"&codFM="+codFM+"&tipo="+tipo;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
        }


        function comboOEspecifico(){
            var id = document.getElementById("codObj").value;
            var idDiv = "comboOESpecifico";
            var metodo = "GET";
            var url = "consultasAjax/comboOEspecificoAjax.jsp?id="+id;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
        }


        function comboAPermanente(){
            var id = document.getElementById("codObjEsp").value;
            var idDiv = "comboAPermanente";
            var metodo = "GET";
            var url = "consultasAjax/comboAPermanenteMFAjax.jsp?id="+id;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);

        }


        function autoCompletarDiv(metodo,url,cadena,async,idDiv)
        {
            if( window.XMLHttpRequest )
                ajax = new XMLHttpRequest();
            else
                ajax = new ActiveXObject("Microsoft.XMLHTTP");
            ELEMENT_DIV = idDiv;
            ajax.onreadystatechange = funcionCallbackVerDiv;
            ajax.open( metodo, url, async);
            ajax.send(cadena);
        }

        function funcionCallbackVerDiv()
        {
            if( ajax.readyState == 4 )
            {
                if( ajax.status == 200 )
                { //alert(ajax.responseText);
                    document.getElementById(ELEMENT_DIV).innerHTML = ajax.responseText;
                }
            }
        }

        function validar(){
            var inicio = Math.floor(document.getElementById("inicio").value);
            var fin = Math.floor(document.getElementById("fin").value);
            for(inicio;inicio<=fin;inicio++){
                document.getElementById("mes"+inicio+"FinaMeta").disabled = false;

            }
            var flag = Math.floor(document.getElementById("flag").value);
            if(flag==0){
                activar();
            }
            if(flag==1){
                desactivar();
            }

        }

        

        function regresar(){

            var form = document.getElementById("PEIForm");
            //form.action="PEI.do?dispatch=listarPlanOperativo";

            //Ini agregado
            var codObjBack = document.getElementById("codObjBack").value;
            var codObjEspBack = document.getElementById("codObjEspBack").value;

            var descObjBack = document.getElementById("descObjBack").value;
            var descObjEspBack = document.getElementById("descObjEspBack").value;

           
            form.action="PEI.do?dispatch=listarPlanOperativo&codObjBack="+codObjBack+"&codObjEspBack="+codObjEspBack+
                "&descObjEspBack="+descObjEspBack+"&descObjBack="+descObjBack;
            //Fin agregado

            form.method="post";

            form.submit();

        }

        function desactivar(){

            PEIForm.grabar.disabled = true;

        }

        function activar(){

            PEIForm.grabar.disabled = false;

        }
    </script>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link type="text/css" rel="stylesheet" href="lib/css/Style_Font_Text.css" >
        <link type="text/css" rel="stylesheet" href="lib/css/Style_PageTable.css" >
        <link type="text/css" rel="stylesheet" href="lib/css/Style_Index.css" >
        <title>JSP Page</title>
    </head>
    <body onload="validar()">
        <center>
            <h1 class="substylo">Meta Financiera</h1>
        </center>
        <div style="overflow: auto; width: 710px; height: 400px">
            <html:form
                action="PEI.do?dispatch=ingresarMetaFinanciera" styleId="PEIForm">
                <html:hidden property="opcionFinaMeta" styleId="opcionFinaMeta"
                             value="1" />
                <html:hidden property="inicio" styleId="inicio" />
                <html:hidden property="fin" styleId="fin" />
                <html:hidden property="flag" styleId="flag" />

                <!--Ini agregado-->
                           <html:hidden property="codObjBack" styleId="codObjBack"/>
                           <html:hidden property="codObjEspBack" styleId="codObjEspBack"/>
                            <html:hidden property="descObjBack" styleId="descObjBack"/>
                           <html:hidden property="descObjEspBack" styleId="descObjEspBack"/>
                <!--Fin agregado-->

                <table border="0" cellspacing="0" style="width: 600px">
                    <tr>
                        <td style="width: 150px">Objetivo General Estrat&eacute;gico</td>
                        <td style="width: 400px">
                            <html:textarea  styleId="descObj" property="descObj"  disabled="true" rows="5" cols="50" styleClass="textarea"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 150px">Objetivo Espec&iacute;fico Estrat&eacute;gico</td>
                        <td style="width: 400px">
                            <html:textarea  styleId="descObjEsp" property="descObjEsp"  disabled="true" rows="5" cols="50" styleClass="textarea"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 150px">Actividad</td>
                        <td style="width: 400px">
                            <html:textarea  styleId="descActPer" property="descActPer"  disabled="true" rows="5" cols="50" styleClass="textarea"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 150px">PPTO</td>
                        <td style="width: 400px">
                            <html:text property="total"  readonly="true" styleId="total" disabled="true" styleClass="text"/>
                        </td>
                    </tr>

                </table>

                <table border="0" cellspacing="0"  style="width: 600px">
                    <tr>
                        <td>Enero:</td>
                        <td><html:text styleId="mes1FinaMeta" property="mes1FinaMeta"
                                   maxlength="400" disabled="true" styleClass="textN"/></td>
                        <td>Febrero:</td>
                        <td><html:text styleId="mes2FinaMeta" property="mes2FinaMeta"
                                   maxlength="400" disabled="true" styleClass="textN"/></td>
                        <td>Marzo:</td>
                        <td><html:text styleId="mes3FinaMeta" property="mes3FinaMeta"
                                   maxlength="400" disabled="true" styleClass="textN"/></td>
                        <td>Abril:</td>
                        <td><html:text styleId="mes4FinaMeta" property="mes4FinaMeta"
                                   maxlength="400" disabled="true" styleClass="textN"/></td>
                    </tr>
                    <tr>
                        <td>Mayo:</td>
                        <td><html:text styleId="mes5FinaMeta" property="mes5FinaMeta"
                                   maxlength="400" disabled="true" styleClass="textN"/></td>
                        <td>Junio:</td>
                        <td><html:text styleId="mes6FinaMeta" property="mes6FinaMeta"
                                   maxlength="400" disabled="true" styleClass="textN"/></td>
                        <td>Julio:</td>
                        <td><html:text styleId="mes7FinaMeta" property="mes7FinaMeta"
                                   maxlength="400" disabled="true" styleClass="textN"/></td>
                        <td>Agosto:</td>
                        <td><html:text styleId="mes8FinaMeta" property="mes8FinaMeta"
                                   maxlength="400" disabled="true" styleClass="textN"/></td>
                    </tr>
                    <tr>
                        <td>Setiembre:</td>
                        <td><html:text styleId="mes9FinaMeta" property="mes9FinaMeta"
                                   maxlength="400" disabled="true" styleClass="textN"/></td>
                        <td>Octubre:</td>
                        <td><html:text styleId="mes10FinaMeta"
                                   property="mes10FinaMeta" maxlength="400" disabled="true" styleClass="textN"/></td>
                        <td>Noviembre:</td>
                        <td><html:text styleId="mes11FinaMeta"
                                   property="mes11FinaMeta" maxlength="400" disabled="true" styleClass="textN"/></td>
                        <td>Diciembre:</td>
                        <td><html:text styleId="mes12FinaMeta"
                                   property="mes12FinaMeta" maxlength="400" disabled="true" styleClass="textN"/></td>
                    </tr>

                    <tr>
                        <td colspan="3">
                            <label style="color: blue"> Solo se permite grabar un registro en este M&oacute;dulo</label>
                        </td>
                    </tr>

                    <html:hidden property="codFinaMeta" styleId="codFinaMeta" />
                    <html:hidden property="codActPer" styleId="codActPer" />


                    <tr><center>
                        <td colspan="4" align="center"><input type="button" id="grabar"
                                                              value="Grabar" onclick="validando()" class="submit2"/>
                            <html:button property="button"  value="regresar" onclick="regresar()" styleClass="submit2"/></td>
                    </center>
                    </tr>

                </table>
                <%int i = 1;%>


                <div id="divTabla">
                    <table width='100%' border="1" align='right' cellspacing="0" class='userTable' id='tabla1'>
                        <tr class='even' align='center'>

                            <th class='textoTR'>#</th>
                            <th class='textoTR'>PPTO Anual</th>
                            <th class='textoTR'>PPTO I Semestre</th>
                            <th class='textoTR'>PPTO II Semestre</th>
                            <th class='textoTR'>Editar</th>
                            <th class='textoTR'>Eliminar</th>
                        </tr>
                        <logic:iterate name="PEIForm" property="listaFinaMeta" id="lista">
                            <tr align="center">
                                <td width="10%" align="center">
                                    <%= i++%>
                                </td>
                                <td width="10%" align="center">
                                    <bean:write name="lista" property="PPto_Anual"/>
                                </td>
                                <td width="10%" align="center">
                                    <bean:write name="lista" property="semestreI"/>
                                </td>
                                <td width="10%" align="center">
                                    <bean:write name="lista" property="semestreII"/>
                                </td>
                                <td width="10%" align="center">
                                    <img style="cursor:pointer" title="Editar" alt="Editar" border=0  src="images/b_edit.png" onclick="editarT('<c:out value="${lista.NUM_CODACTPER_PK}"/>','<c:out value="${lista.NUM_MES1FINAMETA}"/>','<c:out value="${lista.NUM_MES2FINAMETA}"/>','<c:out value="${lista.NUM_MES3FINAMETA}"/>','<c:out value="${lista.NUM_MES4FINAMETA}"/>','<c:out value="${lista.NUM_MES5FINAMETA}"/>','<c:out value="${lista.NUM_MES6FINAMETA}"/>','<c:out value="${lista.NUM_MES7FINAMETA}"/>','<c:out value="${lista.NUM_MES8FINAMETA}"/>','<c:out value="${lista.NUM_MES9FINAMETA}"/>','<c:out value="${lista.NUM_MES10FINAMETA}"/>','<c:out value="${lista.NUM_MES11FINAMETA}"/>','<c:out value="${lista.NUM_MES12FINAMETA}"/>','<c:out value="${lista.NUM_CODFINAMETA_PK}"/>');"/>
                                </td>
                                <td width="10%" align="center">
                                    <img style="cursor:pointer" title="Eliminar" alt="Eliminar" border=0  src="images/b_drop.png" onclick="eliminar('<c:out value="${lista.NUM_CODFINAMETA_PK}"/>','<c:out value="${lista.NUM_CODACTPER_PK}"/>');"/>
                                </td>
                            </tr>
                        </logic:iterate>
                    </table>
                </div>

                <html:hidden property="codFinaMeta" styleId="codFinaMeta" />
                <html:hidden property="codActPer" styleId="codActPer" />
            </html:form>
        </div>
    </body>
</html>